#include "knl_LoggerConfig.h"
#include "knl_timer.h"
#include "..\knl_asynLogger.h"
#include "..\logger_queue\knl_loggerQueue.hpp"


namespace knl
{

	knl_LoggerConfig::knl_LoggerConfig(void)
	{
	}


	knl_LoggerConfig::~knl_LoggerConfig(void)
	{
	}

	std::string knl_LoggerConfig::getWorkDir()
	{
		return "log";
	}

	void knl_LoggerConfig::handlerLogger()
	{
		knl_LoggerNode	_Node = knl_logger()->popNode();

		boost::filesystem::create_directory(getWorkDir());

		std::string szLogFile =boost::str(boost::format("%1/%2_%3.log") % getWorkDir() % "normal" % knl_timer::second_localTime().toDayString());

		std::fstream	_logStream(szLogFile,std::ios::app);

		if (_logStream.is_open())
		{
			std::string szLogString = boost::str(boost::format("[%1][%2] %3") % _Node.get<3>() % _Node.get<0>() % _Node.get<2>());

			std::cout << szLogString << std::endl;
			_logStream << szLogString << std::endl;

			_logStream.flush();
			_logStream.close();
		}
	}

}